Add a guard to prevent cleanup() from running when prepare() was never
called. Currently cleanup() is called when "stopped" is emitted (which
ensures prepare() was called), in next commits cleanup will be called
from different events which means prepare() may not have been called.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4082>
(cherry picked from commit
841ff6cfa247e69ed2c466c880846d1cceb3eece)
if (!duration)
return {prepare: null, cleanup: null};
+ let canCleanup = false;
const prepare = () => {
global.compositor.disable_unredirect();
global.begin_work();
+ canCleanup = true;
};
const cleanup = () => {
+ if (!canCleanup)
+ return;
global.compositor.enable_unredirect();
global.end_work();
};